package com.mi.soul.whale.module.system.controller;

import com.mi.rule.auth.Public;
import com.mi.rule.resource.ResC;
import com.mi.rule.resource.ResM;
import com.mi.rule.util.project.SRS;
import com.mi.soul.whale.module.system.service.DictService;
import com.mi.soul.whale.module.system.service.impl.SystemServiceImpl;
import com.mi.soul.whale.mybatis.entity.SysDict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ResC(value = "字典管理", parent = "系统管理")
@RequestMapping("/system/dict")
public class DictController {
    @Autowired
    SystemServiceImpl systemService;
    @Autowired
    DictService dictService;

    // 摘除或换位置
    @Public
    @ResM("前端字典信息")
    @RequestMapping({"/manage/public/dictList"})
    public SRS dictList() {
        return SRS.bySuccess(
                SRS.create()
                        .set("showLog", dictService.getValue("manage_font_is_show_log"))
                        .set("imageBseUrl", dictService.getValue("manage_image_ip"))
                        .set("socketUrl", dictService.getValue("manage_socket_ip"))
        );
    }

    @ResM("添加字典")
    @RequestMapping({"/insert"})
    public SRS insert(@RequestBody SysDict dict) {
        return systemService.insertDict(dict);
    }


    @ResM("删除字典")
    @RequestMapping({"/delete"})
    public SRS delete(@RequestBody Object[] ids) {
        return systemService.deleteDict(ids);
    }


    @ResM("修改字典")
    @RequestMapping({"/update"})
    public SRS update(@RequestBody SysDict dict) {
        return systemService.updateDict(dict);
    }


    @ResM("字典分页查询")
    @RequestMapping("/page")
    public SRS page(@RequestBody SRS param) {
        return systemService.pageDict(param);
    }

    @ResM("字典列表查询")
    @RequestMapping({"/list"})
    public SRS list(@RequestBody SRS param) {
        return systemService.listDict(param);
    }

    @ResM("字典详情查询")
    @RequestMapping("/info")
    public SRS one(@RequestBody SRS param) {
        return systemService.infoDict(param);
    }

}
